From bfb0bf8f2e5f8291335c652f6ce1da735f1aa84e Mon Sep 17 00:00:00 2001 From: robertlipe Date: Thu, 13 Feb 2014 00:12:48 +0000 Subject: [PATCH] Make the jeeps code somewhat less weird w.r.t. packet allocation and deallocation, letting the life cycle of the objects take care of zeroing buffers and releasing them. This same stick should be shaken at other code in jeeps... Tested: Reads and writes of waypoints on 60CSX on Mac USB with address sanitizer. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4731 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/jeeps/gps.h | 22 +- gpsbabel/jeeps/gpsapp.cc | 530 ++++++++++------------------------- gpsbabel/jeeps/gpsapp.h | 9 - gpsbabel/jeeps/gpscom.cc | 7 - gpsbabel/jeeps/gpscom.h | 9 - gpsbabel/jeeps/gpsdatum.h | 9 - gpsbabel/jeeps/gpsdevice.cc | 6 +- gpsbabel/jeeps/gpsdevice.h | 9 - gpsbabel/jeeps/gpsfmt.h | 9 - gpsbabel/jeeps/gpsinput.h | 9 - gpsbabel/jeeps/gpsmath.h | 9 - gpsbabel/jeeps/gpsmem.cc | 49 ---- gpsbabel/jeeps/gpsmem.h | 12 - gpsbabel/jeeps/gpsproj.h | 9 - gpsbabel/jeeps/gpsprot.h | 9 - gpsbabel/jeeps/gpsread.cc | 28 +- gpsbabel/jeeps/gpsread.h | 9 - gpsbabel/jeeps/gpsrqst.cc | 18 -- gpsbabel/jeeps/gpsrqst.h | 9 - gpsbabel/jeeps/gpssend.cc | 19 +- gpsbabel/jeeps/gpssend.h | 9 - gpsbabel/jeeps/gpsserial.h | 9 - gpsbabel/jeeps/gpsusbread.cc | 6 +- gpsbabel/jeeps/gpsusbsend.cc | 8 +- gpsbabel/jeeps/gpsutil.h | 9 - gpsbabel/mmo.cc | 2 + 26 files changed, 191 insertions(+), 642 deletions(-) diff --git a/gpsbabel/jeeps/gps.h b/gpsbabel/jeeps/gps.h index 12f30eaf2..7da64b6be 100644 --- a/gpsbabel/jeeps/gps.h +++ b/gpsbabel/jeeps/gps.h @@ -1,8 +1,3 @@ -#ifdef __cplusplus -// extern "C" -//{ -#endif - #ifndef gps_h #define gps_h @@ -40,7 +35,18 @@ typedef struct GPS_SPacket { US type; uint32 n; UC* data; -} GPS_OPacket, *GPS_PPacket; +} GPS_OPacket; + +class GPS_PPacket { +public: + GPS_PPacket() : type(0), n(0) { + memset(data, 0, MAX_GPS_PACKET_SIZE); + } + US type; + uint32 n; + UC data[MAX_GPS_PACKET_SIZE]; +}; + typedef struct GPS_Serial_SPacket { UC dle; @@ -282,7 +288,3 @@ extern char* gps_16_sym[]; #endif - -#ifdef __cplusplus -// } -#endif diff --git a/gpsbabel/jeeps/gpsapp.cc b/gpsbabel/jeeps/gpsapp.cc index 34bbc70b4..525590da2 100644 --- a/gpsbabel/jeeps/gpsapp.cc +++ b/gpsbabel/jeeps/gpsapp.cc @@ -211,10 +211,6 @@ static int32 GPS_A000(const char* port) return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Make_Packet(&tra, LINK_ID[0].Pid_Product_Rqst,NULL,0); if (!GPS_Write_Packet(fd,tra)) { return SERIAL_ERROR; @@ -227,10 +223,10 @@ static int32 GPS_A000(const char* port) GPS_Packet_Read(fd, &rec); GPS_Send_Ack(fd, &tra, &rec); - id = GPS_Util_Get_Short(rec->data); - version = GPS_Util_Get_Short((rec->data)+2); + id = GPS_Util_Get_Short(rec.data); + version = GPS_Util_Get_Short((rec.data)+2); - (void) strcpy(gps_save_string,(char*)rec->data+4); + (void) strcpy(gps_save_string,(char*)rec.data+4); gps_save_id = id; gps_save_version = (double)((double)version/(double)100.); @@ -317,7 +313,7 @@ static int32 GPS_A000(const char* port) * reach behind that automation here and hand that ourselves. */ for (i = 0; i < 25; i++) { - rec->type = 0; + rec.type = 0; if (gps_is_usb) { GPS_Packet_Read_usb(fd, &rec, 0); @@ -333,7 +329,7 @@ static int32 GPS_A000(const char* port) GPS_Send_Ack(fd, &tra, &rec); } - if (rec->type == 0xfd) { + if (rec.type == 0xfd) { GPS_A001(rec); goto carry_on; } @@ -347,7 +343,7 @@ static int32 GPS_A000(const char* port) * * Garmin acknowledges this is a firmware defect. */ - if (rec->type < 0xf8) { + if (rec.type < 0xf8) { i = 0; } } @@ -360,9 +356,6 @@ carry_on: GPS_A800_Off(port,&fd); } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -391,8 +384,8 @@ static void GPS_A001(GPS_PPacket packet) US data; US lasta=0; - entries = packet->n / 3; - p = packet->data; + entries = packet.n / 3; + p = packet.data; for (i=0; idata); + n = GPS_Util_Get_Short(rec.data); if (n) if (!((*way)=(GPS_PWay*)malloc(n*sizeof(GPS_PWay)))) { @@ -918,52 +907,52 @@ int32 GPS_A100_Get(const char* port, GPS_PWay** way, int (*cb)(int, GPS_PWay*)) switch (gps_waypt_type) { case pD100: - GPS_D100_Get(&((*way)[i]),rec->data); + GPS_D100_Get(&((*way)[i]),rec.data); break; case pD101: - GPS_D101_Get(&((*way)[i]),rec->data); + GPS_D101_Get(&((*way)[i]),rec.data); break; case pD102: - GPS_D102_Get(&((*way)[i]),rec->data); + GPS_D102_Get(&((*way)[i]),rec.data); break; case pD103: - GPS_D103_Get(&((*way)[i]),rec->data); + GPS_D103_Get(&((*way)[i]),rec.data); break; case pD104: - GPS_D104_Get(&((*way)[i]),rec->data); + GPS_D104_Get(&((*way)[i]),rec.data); break; case pD105: - GPS_D105_Get(&((*way)[i]),rec->data); + GPS_D105_Get(&((*way)[i]),rec.data); break; case pD106: - GPS_D106_Get(&((*way)[i]),rec->data); + GPS_D106_Get(&((*way)[i]),rec.data); break; case pD107: - GPS_D107_Get(&((*way)[i]),rec->data); + GPS_D107_Get(&((*way)[i]),rec.data); break; case pD108: - GPS_D108_Get(&((*way)[i]),rec->data); + GPS_D108_Get(&((*way)[i]),rec.data); break; case pD109: - GPS_D109_Get(&((*way)[i]),rec->data, 109); + GPS_D109_Get(&((*way)[i]),rec.data, 109); break; case pD110: - GPS_D109_Get(&((*way)[i]),rec->data, 110); + GPS_D109_Get(&((*way)[i]),rec.data, 110); break; case pD150: - GPS_D150_Get(&((*way)[i]),rec->data); + GPS_D150_Get(&((*way)[i]),rec.data); break; case pD151: - GPS_D151_Get(&((*way)[i]),rec->data); + GPS_D151_Get(&((*way)[i]),rec.data); break; case pD152: - GPS_D152_Get(&((*way)[i]),rec->data); + GPS_D152_Get(&((*way)[i]),rec.data); break; case pD154: - GPS_D154_Get(&((*way)[i]),rec->data); + GPS_D154_Get(&((*way)[i]),rec.data); break; case pD155: - GPS_D155_Get(&((*way)[i]),rec->data); + GPS_D155_Get(&((*way)[i]),rec.data); break; default: GPS_Error("A100_GET: Unknown waypoint protocol: %d", gps_waypt_type); @@ -982,8 +971,8 @@ int32 GPS_A100_Get(const char* port, GPS_PWay** way, int (*cb)(int, GPS_PWay*)) return gps_errno; } - if (rec->type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { - GPS_Error("A100_GET: Error transferring waypoints. Expected %d completion code. Got %d. %d of %d received", LINK_ID[gps_link_type].Pid_Xfer_Cmplt, rec->type, i, n); + if (rec.type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { + GPS_Error("A100_GET: Error transferring waypoints. Expected %d completion code. Got %d. %d of %d received", LINK_ID[gps_link_type].Pid_Xfer_Cmplt, rec.type, i, n); return FRAMING_ERROR; } @@ -992,9 +981,6 @@ int32 GPS_A100_Get(const char* port, GPS_PWay** way, int (*cb)(int, GPS_PWay*)) return FRAMING_ERROR; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -1029,10 +1015,6 @@ int32 GPS_A100_Send(const char* port, GPS_PWay* way, int32 n, int (*cb)(GPS_PWay return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, (short) n); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Records, data,2); @@ -1130,9 +1112,6 @@ int32 GPS_A100_Send(const char* port, GPS_PWay* way, int32 n, int (*cb)(GPS_PWay return gps_errno; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -1158,10 +1137,6 @@ int32 GPS_A101_Get(const char* port) return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, COMMAND_ID[gps_device_command].Cmnd_Transfer_Wpt_Cats); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Command_Data, @@ -1180,7 +1155,7 @@ int32 GPS_A101_Get(const char* port) GPS_Packet_Read(fd, &rec); GPS_Send_Ack(fd, &tra, &rec); - n = GPS_Util_Get_Short(rec->data); + n = GPS_Util_Get_Short(rec.data); for (i = 0; i < n; ++i) { if (!GPS_Packet_Read(fd, &rec)) { return gps_errno; @@ -1190,7 +1165,7 @@ int32 GPS_A101_Get(const char* port) } switch (gps_category_type) { case pD120: - GPS_D120_Get(i,(char*) rec->data); + GPS_D120_Get(i,(char*) rec.data); break; } } @@ -1201,8 +1176,8 @@ int32 GPS_A101_Get(const char* port) return gps_errno; } - if (rec->type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { - GPS_Error("A101_Get: Error transferring waypoints. Expected %d completion code. Got %d. %d of %d received", LINK_ID[gps_link_type].Pid_Xfer_Cmplt, rec->type, i, n); + if (rec.type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { + GPS_Error("A101_Get: Error transferring waypoints. Expected %d completion code. Got %d. %d of %d received", LINK_ID[gps_link_type].Pid_Xfer_Cmplt, rec.type, i, n); return FRAMING_ERROR; } @@ -2816,10 +2791,6 @@ int32 GPS_A200_Get(const char* port, GPS_PWay** way) return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, COMMAND_ID[gps_device_command].Cmnd_Transfer_Rte); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Command_Data, @@ -2838,7 +2809,7 @@ int32 GPS_A200_Get(const char* port, GPS_PWay** way) return gps_errno; } - n = GPS_Util_Get_Short(rec->data); + n = GPS_Util_Get_Short(rec.data); if (n) if (!((*way)=(GPS_PWay*)malloc(n*sizeof(GPS_PWay)))) { @@ -2859,16 +2830,16 @@ int32 GPS_A200_Get(const char* port, GPS_PWay** way) return gps_errno; } - if (rec->type == LINK_ID[gps_link_type].Pid_Rte_Hdr) { + if (rec.type == LINK_ID[gps_link_type].Pid_Rte_Hdr) { switch (gps_rte_hdr_type) { case pD200: - GPS_D200_Get(&((*way)[i]),rec->data); + GPS_D200_Get(&((*way)[i]),rec.data); break; case pD201: - GPS_D201_Get(&((*way)[i]),rec->data); + GPS_D201_Get(&((*way)[i]),rec.data); break; case pD202: - GPS_D202_Get(&((*way)[i]),rec->data); + GPS_D202_Get(&((*way)[i]),rec.data); break; default: GPS_Error("A200_GET: Unknown route protocol"); @@ -2877,7 +2848,7 @@ int32 GPS_A200_Get(const char* port, GPS_PWay** way) continue; } - if (rec->type != LINK_ID[gps_link_type].Pid_Rte_Wpt_Data) { + if (rec.type != LINK_ID[gps_link_type].Pid_Rte_Wpt_Data) { GPS_Error("A200_GET: Non Pid_rte_Wpt_Data"); return FRAMING_ERROR; } @@ -2887,52 +2858,52 @@ int32 GPS_A200_Get(const char* port, GPS_PWay** way) switch (gps_rte_type) { case pD100: - GPS_D100_Get(&((*way)[i]),rec->data); + GPS_D100_Get(&((*way)[i]),rec.data); break; case pD101: - GPS_D101_Get(&((*way)[i]),rec->data); + GPS_D101_Get(&((*way)[i]),rec.data); break; case pD102: - GPS_D102_Get(&((*way)[i]),rec->data); + GPS_D102_Get(&((*way)[i]),rec.data); break; case pD103: - GPS_D103_Get(&((*way)[i]),rec->data); + GPS_D103_Get(&((*way)[i]),rec.data); break; case pD104: - GPS_D104_Get(&((*way)[i]),rec->data); + GPS_D104_Get(&((*way)[i]),rec.data); break; case pD105: - GPS_D105_Get(&((*way)[i]),rec->data); + GPS_D105_Get(&((*way)[i]),rec.data); break; case pD106: - GPS_D106_Get(&((*way)[i]),rec->data); + GPS_D106_Get(&((*way)[i]),rec.data); break; case pD107: - GPS_D107_Get(&((*way)[i]),rec->data); + GPS_D107_Get(&((*way)[i]),rec.data); break; case pD108: - GPS_D108_Get(&((*way)[i]),rec->data); + GPS_D108_Get(&((*way)[i]),rec.data); break; case pD109: - GPS_D109_Get(&((*way)[i]),rec->data,109); + GPS_D109_Get(&((*way)[i]),rec.data,109); break; case pD110: - GPS_D109_Get(&((*way)[i]),rec->data,110); + GPS_D109_Get(&((*way)[i]),rec.data,110); break; case pD150: - GPS_D150_Get(&((*way)[i]),rec->data); + GPS_D150_Get(&((*way)[i]),rec.data); break; case pD151: - GPS_D151_Get(&((*way)[i]),rec->data); + GPS_D151_Get(&((*way)[i]),rec.data); break; case pD152: - GPS_D152_Get(&((*way)[i]),rec->data); + GPS_D152_Get(&((*way)[i]),rec.data); break; case pD154: - GPS_D154_Get(&((*way)[i]),rec->data); + GPS_D154_Get(&((*way)[i]),rec.data); break; case pD155: - GPS_D155_Get(&((*way)[i]),rec->data); + GPS_D155_Get(&((*way)[i]),rec.data); break; default: GPS_Error("A200_GET: Unknown route protocol"); @@ -2949,7 +2920,7 @@ int32 GPS_A200_Get(const char* port, GPS_PWay** way) return gps_errno; } - if (rec->type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { + if (rec.type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { GPS_Error("A200_GET: Error transferring routes"); return FRAMING_ERROR; } @@ -2959,9 +2930,6 @@ int32 GPS_A200_Get(const char* port, GPS_PWay** way) return FRAMING_ERROR; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; @@ -2995,10 +2963,6 @@ int32 GPS_A201_Get(const char* port, GPS_PWay** way) return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, COMMAND_ID[gps_device_command].Cmnd_Transfer_Rte); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Command_Data, @@ -3017,7 +2981,7 @@ int32 GPS_A201_Get(const char* port, GPS_PWay** way) return gps_errno; } - n = GPS_Util_Get_Short(rec->data); + n = GPS_Util_Get_Short(rec.data); if (n) if (!((*way)=(GPS_PWay*)malloc(n*sizeof(GPS_PWay)))) { @@ -3038,16 +3002,16 @@ int32 GPS_A201_Get(const char* port, GPS_PWay** way) return gps_errno; } - if (rec->type == LINK_ID[gps_link_type].Pid_Rte_Hdr) { + if (rec.type == LINK_ID[gps_link_type].Pid_Rte_Hdr) { switch (gps_rte_hdr_type) { case pD200: - GPS_D200_Get(&((*way)[i]),rec->data); + GPS_D200_Get(&((*way)[i]),rec.data); break; case pD201: - GPS_D201_Get(&((*way)[i]),rec->data); + GPS_D201_Get(&((*way)[i]),rec.data); break; case pD202: - GPS_D202_Get(&((*way)[i]),rec->data); + GPS_D202_Get(&((*way)[i]),rec.data); break; default: GPS_Error("A201_GET: Unknown route protocol"); @@ -3058,10 +3022,10 @@ int32 GPS_A201_Get(const char* port, GPS_PWay** way) } - if (rec->type == LINK_ID[gps_link_type].Pid_Rte_Link_Data) { + if (rec.type == LINK_ID[gps_link_type].Pid_Rte_Link_Data) { switch (gps_rte_link_type) { case pD210: - GPS_D210_Get(&((*way)[i]),rec->data); + GPS_D210_Get(&((*way)[i]),rec.data); break; default: GPS_Error("A201_GET: Unknown route protocol"); @@ -3072,7 +3036,7 @@ int32 GPS_A201_Get(const char* port, GPS_PWay** way) continue; } - if (rec->type != LINK_ID[gps_link_type].Pid_Rte_Wpt_Data) { + if (rec.type != LINK_ID[gps_link_type].Pid_Rte_Wpt_Data) { GPS_Error("A200_GET: Non Pid_rte_Wpt_Data"); return FRAMING_ERROR; } @@ -3082,52 +3046,52 @@ int32 GPS_A201_Get(const char* port, GPS_PWay** way) switch (gps_rte_type) { case pD100: - GPS_D100_Get(&((*way)[i]),rec->data); + GPS_D100_Get(&((*way)[i]),rec.data); break; case pD101: - GPS_D101_Get(&((*way)[i]),rec->data); + GPS_D101_Get(&((*way)[i]),rec.data); break; case pD102: - GPS_D102_Get(&((*way)[i]),rec->data); + GPS_D102_Get(&((*way)[i]),rec.data); break; case pD103: - GPS_D103_Get(&((*way)[i]),rec->data); + GPS_D103_Get(&((*way)[i]),rec.data); break; case pD104: - GPS_D104_Get(&((*way)[i]),rec->data); + GPS_D104_Get(&((*way)[i]),rec.data); break; case pD105: - GPS_D105_Get(&((*way)[i]),rec->data); + GPS_D105_Get(&((*way)[i]),rec.data); break; case pD106: - GPS_D106_Get(&((*way)[i]),rec->data); + GPS_D106_Get(&((*way)[i]),rec.data); break; case pD107: - GPS_D107_Get(&((*way)[i]),rec->data); + GPS_D107_Get(&((*way)[i]),rec.data); break; case pD108: - GPS_D108_Get(&((*way)[i]),rec->data); + GPS_D108_Get(&((*way)[i]),rec.data); break; case pD109: - GPS_D109_Get(&((*way)[i]),rec->data,109); + GPS_D109_Get(&((*way)[i]),rec.data,109); break; case pD110: - GPS_D109_Get(&((*way)[i]),rec->data,110); + GPS_D109_Get(&((*way)[i]),rec.data,110); break; case pD150: - GPS_D150_Get(&((*way)[i]),rec->data); + GPS_D150_Get(&((*way)[i]),rec.data); break; case pD151: - GPS_D151_Get(&((*way)[i]),rec->data); + GPS_D151_Get(&((*way)[i]),rec.data); break; case pD152: - GPS_D152_Get(&((*way)[i]),rec->data); + GPS_D152_Get(&((*way)[i]),rec.data); break; case pD154: - GPS_D154_Get(&((*way)[i]),rec->data); + GPS_D154_Get(&((*way)[i]),rec.data); break; case pD155: - GPS_D155_Get(&((*way)[i]),rec->data); + GPS_D155_Get(&((*way)[i]),rec.data); break; default: GPS_Error("A200_GET: Unknown route protocol"); @@ -3144,7 +3108,7 @@ int32 GPS_A201_Get(const char* port, GPS_PWay** way) return gps_errno; } - if (rec->type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { + if (rec.type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { GPS_Error("A200_GET: Error transferring routes"); return FRAMING_ERROR; } @@ -3154,9 +3118,6 @@ int32 GPS_A201_Get(const char* port, GPS_PWay** way) return FRAMING_ERROR; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; @@ -3191,10 +3152,6 @@ int32 GPS_A200_Send(const char* port, GPS_PWay* way, int32 n) return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data,(US) n); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Records, data,2); @@ -3301,9 +3258,6 @@ int32 GPS_A200_Send(const char* port, GPS_PWay* way, int32 n) return FRAMING_ERROR; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -3337,10 +3291,6 @@ int32 GPS_A201_Send(const char* port, GPS_PWay* way, int32 n) return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data,(US) n); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Records, data,2); @@ -3464,9 +3414,6 @@ int32 GPS_A201_Send(const char* port, GPS_PWay* way, int32 n) return FRAMING_ERROR; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -3727,10 +3674,6 @@ int32 GPS_A300_Get(const char* port, GPS_PTrack** trk, pcb_fn cb) return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, COMMAND_ID[gps_device_command].Cmnd_Transfer_Trk); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Command_Data, @@ -3749,7 +3692,7 @@ int32 GPS_A300_Get(const char* port, GPS_PTrack** trk, pcb_fn cb) } - n = GPS_Util_Get_Short(rec->data); + n = GPS_Util_Get_Short(rec.data); if (n) if (!((*trk)=(GPS_PTrack*)malloc(n*sizeof(GPS_PTrack)))) { @@ -3778,9 +3721,6 @@ int32 GPS_A300_Get(const char* port, GPS_PTrack** trk, pcb_fn cb) return FRAMING_ERROR; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -3806,10 +3746,6 @@ drain_run_cmd(gpsdevh* fd) GPS_PPacket rec; static UC data[2]; - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, COMMAND_ID[gps_device_command].Cmnd_Transfer_Runs); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Command_Data, @@ -3829,13 +3765,11 @@ drain_run_cmd(gpsdevh* fd) if (!GPS_Send_Ack(fd, &tra, &rec)) { return gps_errno; } - if (rec->type == LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { + if (rec.type == LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { break; } } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); return 0; } @@ -3899,10 +3833,6 @@ int32 GPS_A301_Get(const char* port, GPS_PTrack** trk, pcb_fn cb, int protoid) drain_run_cmd(fd); } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, Cmnd_Transfer_Trk); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Command_Data, data,2); @@ -3920,7 +3850,7 @@ int32 GPS_A301_Get(const char* port, GPS_PTrack** trk, pcb_fn cb, int protoid) } - n = GPS_Util_Get_Short(rec->data); + n = GPS_Util_Get_Short(rec.data); if (n) if (!((*trk)=(GPS_PTrack*)malloc(n*sizeof(GPS_PTrack)))) { @@ -3939,14 +3869,14 @@ int32 GPS_A301_Get(const char* port, GPS_PTrack** trk, pcb_fn cb, int protoid) if (!GPS_Send_Ack(fd, &tra, &rec)) { return gps_errno; } - if (rec->type == Pid_Trk_Hdr) { + if (rec.type == Pid_Trk_Hdr) { switch (trk_hdr_type) { case pD310: case pD312: - GPS_D310_Get(&((*trk)[i]),rec->data); + GPS_D310_Get(&((*trk)[i]),rec.data); break; case pD311: - GPS_D311_Get(&((*trk)[i]),rec->data); + GPS_D311_Get(&((*trk)[i]),rec.data); break; default: GPS_Error("A301_Get: Unknown track protocol"); @@ -3956,7 +3886,7 @@ int32 GPS_A301_Get(const char* port, GPS_PTrack** trk, pcb_fn cb, int protoid) continue; } - if (rec->type != Pid_Trk_Data) { + if (rec.type != Pid_Trk_Data) { GPS_Error("A301_Get: Non-Pid_Trk_Data"); return FRAMING_ERROR; } @@ -3965,17 +3895,17 @@ int32 GPS_A301_Get(const char* port, GPS_PTrack** trk, pcb_fn cb, int protoid) switch (trk_type) { case pD300: - GPS_D300b_Get(&((*trk)[i]),rec->data); + GPS_D300b_Get(&((*trk)[i]),rec.data); break; case pD301: - GPS_D301b_Get(&((*trk)[i]),rec->data); + GPS_D301b_Get(&((*trk)[i]),rec.data); break; case pD302: - GPS_D302b_Get(&((*trk)[i]),rec->data); + GPS_D302b_Get(&((*trk)[i]),rec.data); break; case pD303: case pD304: - GPS_D303b_Get(&((*trk)[i]),rec->data); + GPS_D303b_Get(&((*trk)[i]),rec.data); /* Fitness devices don't send track segment markers, so we have * to create them ourselves. We do so at the beginning of the * track or if the device signals a pause by sending two @@ -4005,7 +3935,7 @@ int32 GPS_A301_Get(const char* port, GPS_PTrack** trk, pcb_fn cb, int protoid) if (!GPS_Send_Ack(fd, &tra, &rec)) { return gps_errno; } - if (rec->type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { + if (rec.type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { GPS_Error("A301_Get: Error transferring tracks"); return FRAMING_ERROR; } @@ -4015,9 +3945,6 @@ int32 GPS_A301_Get(const char* port, GPS_PTrack** trk, pcb_fn cb, int protoid) return FRAMING_ERROR; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -4059,10 +3986,6 @@ int32 GPS_A300_Send(const char* port, GPS_PTrack* trk, int32 n) return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data,(US) n); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Records, data,2); @@ -4108,9 +4031,6 @@ int32 GPS_A300_Send(const char* port, GPS_PTrack* trk, int32 n) return FRAMING_ERROR; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -4182,10 +4102,6 @@ int32 GPS_A301_Send(const char* port, GPS_PTrack* trk, int32 n, int protoid, return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data,(US) n); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Records, data,2); @@ -4260,9 +4176,6 @@ int32 GPS_A301_Send(const char* port, GPS_PTrack* trk, int32 n, int protoid, return FRAMING_ERROR; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (protoid != 302 && !GPS_Device_Off(fd)) { return gps_errno; } @@ -4287,10 +4200,6 @@ int32 GPS_D300_Get(GPS_PTrack* trk, int32 entries, gpsdevh* fd) GPS_PPacket rec; int32 i; - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - for (i=0; idata, &trk[i]); + GPS_A300_Translate(rec.data, &trk[i]); } @@ -4312,14 +4221,11 @@ int32 GPS_D300_Get(GPS_PTrack* trk, int32 entries, gpsdevh* fd) } - if (rec->type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { + if (rec.type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { GPS_Error("D300_GET: Error transferring track log"); return FRAMING_ERROR; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - return i; } @@ -4836,10 +4742,6 @@ int32 GPS_A400_Get(const char* port, GPS_PWay** way) return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, COMMAND_ID[gps_device_command].Cmnd_Transfer_Prx); @@ -4854,8 +4756,6 @@ int32 GPS_A400_Get(const char* port, GPS_PWay** way) if (!GPS_Device_Chars_Ready(fd)) { GPS_Warning("A400 (ppx) protocol not supported"); - GPS_Packet_Del(&rec); - GPS_Packet_Del(&tra); if (!GPS_Device_Off(fd)) { return gps_errno; @@ -4872,7 +4772,7 @@ int32 GPS_A400_Get(const char* port, GPS_PWay** way) return gps_errno; } - n = GPS_Util_Get_Short(rec->data); + n = GPS_Util_Get_Short(rec.data); if (n) if (!((*way)=(GPS_PWay*)malloc(n*sizeof(GPS_PWay)))) { @@ -4896,52 +4796,52 @@ int32 GPS_A400_Get(const char* port, GPS_PWay** way) switch (gps_prx_waypt_type) { case pD400: - GPS_D400_Get(&((*way)[i]),rec->data); + GPS_D400_Get(&((*way)[i]),rec.data); break; case pD101: - GPS_D101_Get(&((*way)[i]),rec->data); + GPS_D101_Get(&((*way)[i]),rec.data); break; case pD102: - GPS_D102_Get(&((*way)[i]),rec->data); + GPS_D102_Get(&((*way)[i]),rec.data); break; case pD403: - GPS_D403_Get(&((*way)[i]),rec->data); + GPS_D403_Get(&((*way)[i]),rec.data); break; case pD104: - GPS_D104_Get(&((*way)[i]),rec->data); + GPS_D104_Get(&((*way)[i]),rec.data); break; case pD105: - GPS_D105_Get(&((*way)[i]),rec->data); + GPS_D105_Get(&((*way)[i]),rec.data); break; case pD106: - GPS_D106_Get(&((*way)[i]),rec->data); + GPS_D106_Get(&((*way)[i]),rec.data); break; case pD107: - GPS_D107_Get(&((*way)[i]),rec->data); + GPS_D107_Get(&((*way)[i]),rec.data); break; case pD108: - GPS_D108_Get(&((*way)[i]),rec->data); + GPS_D108_Get(&((*way)[i]),rec.data); break; case pD109: - GPS_D109_Get(&((*way)[i]),rec->data,109); + GPS_D109_Get(&((*way)[i]),rec.data,109); break; case pD110: - GPS_D109_Get(&((*way)[i]),rec->data,110); + GPS_D109_Get(&((*way)[i]),rec.data,110); break; case pD450: - GPS_D450_Get(&((*way)[i]),rec->data); + GPS_D450_Get(&((*way)[i]),rec.data); break; case pD151: - GPS_D151_Get(&((*way)[i]),rec->data); + GPS_D151_Get(&((*way)[i]),rec.data); break; case pD152: - GPS_D152_Get(&((*way)[i]),rec->data); + GPS_D152_Get(&((*way)[i]),rec.data); break; case pD154: - GPS_D154_Get(&((*way)[i]),rec->data); + GPS_D154_Get(&((*way)[i]),rec.data); break; case pD155: - GPS_D155_Get(&((*way)[i]),rec->data); + GPS_D155_Get(&((*way)[i]),rec.data); break; default: GPS_Error("A400_GET: Unknown prx waypoint protocol"); @@ -4956,7 +4856,7 @@ int32 GPS_A400_Get(const char* port, GPS_PWay** way) return gps_errno; } - if (rec->type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { + if (rec.type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { GPS_Error("A400_GET: Error transferring prx waypoints"); return FRAMING_ERROR; } @@ -4966,10 +4866,6 @@ int32 GPS_A400_Get(const char* port, GPS_PWay** way) return FRAMING_ERROR; } - - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -5006,10 +4902,6 @@ int32 GPS_A400_Send(const char* port, GPS_PWay* way, int32 n) return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data,(US) n); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Records, @@ -5096,9 +4988,6 @@ int32 GPS_A400_Send(const char* port, GPS_PWay* way, int32 n) return FRAMING_ERROR; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -5410,10 +5299,6 @@ int32 GPS_A500_Get(const char* port, GPS_PAlmanac** alm) return gps_errno; } - if (!(trapkt = GPS_Packet_New()) || !(recpkt = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, COMMAND_ID[gps_device_command].Cmnd_Transfer_Alm); GPS_Make_Packet(&trapkt, LINK_ID[gps_link_type].Pid_Command_Data, @@ -5431,7 +5316,7 @@ int32 GPS_A500_Get(const char* port, GPS_PAlmanac** alm) return gps_errno; } - n = GPS_Util_Get_Short(recpkt->data); + n = GPS_Util_Get_Short(recpkt.data); if (n) if (!((*alm)=(GPS_PAlmanac*)malloc(n*sizeof(GPS_PAlmanac)))) { @@ -5453,20 +5338,20 @@ int32 GPS_A500_Get(const char* port, GPS_PAlmanac** alm) switch (gps_almanac_type) { case pD500: - GPS_A500_Translate(recpkt->data, &((*alm)[i])); + GPS_A500_Translate(recpkt.data, &((*alm)[i])); break; case pD501: - GPS_A500_Translate(recpkt->data, &((*alm)[i])); - (*alm)[i]->hlth=recpkt->data[42]; + GPS_A500_Translate(recpkt.data, &((*alm)[i])); + (*alm)[i]->hlth=recpkt.data[42]; break; case pD550: - (*alm)[i]->svid = recpkt->data[0]; - GPS_A500_Translate(recpkt->data+1, &((*alm)[i])); + (*alm)[i]->svid = recpkt.data[0]; + GPS_A500_Translate(recpkt.data+1, &((*alm)[i])); break; case pD551: - (*alm)[i]->svid = recpkt->data[0]; - GPS_A500_Translate(recpkt->data+1, &((*alm)[i])); - (*alm)[i]->hlth = recpkt->data[43]; + (*alm)[i]->svid = recpkt.data[0]; + GPS_A500_Translate(recpkt.data+1, &((*alm)[i])); + (*alm)[i]->hlth = recpkt.data[43]; break; default: GPS_Error("A500_GET: Unknown almanac protocol"); @@ -5482,7 +5367,7 @@ int32 GPS_A500_Get(const char* port, GPS_PAlmanac** alm) if (!GPS_Send_Ack(fd, &trapkt, &recpkt)) { return gps_errno; } - if (recpkt->type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { + if (recpkt.type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { GPS_Error("A500_Get: Error transferring almanac"); return FRAMING_ERROR; } @@ -5492,9 +5377,6 @@ int32 GPS_A500_Get(const char* port, GPS_PAlmanac** alm) return FRAMING_ERROR; } - GPS_Packet_Del(&trapkt); - GPS_Packet_Del(&recpkt); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -5529,10 +5411,6 @@ int32 GPS_A500_Send(const char* port, GPS_PAlmanac* alm, int32 n) return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data,(US) n); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Records, @@ -5551,8 +5429,6 @@ int32 GPS_A500_Send(const char* port, GPS_PAlmanac* alm, int32 n) case pD500: if (n!=32) { GPS_Error("A500_Send: SATELLITES: n!=32 specified"); - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); return PROTOCOL_ERROR; } GPS_D500_Send(data,alm[i]); @@ -5561,8 +5437,6 @@ int32 GPS_A500_Send(const char* port, GPS_PAlmanac* alm, int32 n) case pD501: if (n!=32) { GPS_Error("A500_Send: SATELLITES: n!=32 specified"); - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); return PROTOCOL_ERROR; } GPS_D501_Send(data,alm[i]); @@ -5621,8 +5495,8 @@ int32 GPS_A500_Send(const char* port, GPS_PAlmanac* alm, int32 n) return gps_errno; } - if (rec->type == LINK_ID[gps_link_type].Pid_Command_Data && - GPS_Util_Get_Short(rec->data) == COMMAND_ID[gps_device_command]. + if (rec.type == LINK_ID[gps_link_type].Pid_Command_Data && + GPS_Util_Get_Short(rec.data) == COMMAND_ID[gps_device_command]. Cmnd_Transfer_Time) { GPS_User("INFO: GPS time request. Sending...."); ret = GPS_Rqst_Send_Time(fd,gps_save_time); @@ -5649,8 +5523,8 @@ int32 GPS_A500_Send(const char* port, GPS_PAlmanac* alm, int32 n) return gps_errno; } - if (rec->type == LINK_ID[gps_link_type].Pid_Command_Data && - GPS_Util_Get_Short(rec->data) == COMMAND_ID[gps_device_command]. + if (rec.type == LINK_ID[gps_link_type].Pid_Command_Data && + GPS_Util_Get_Short(rec.data) == COMMAND_ID[gps_device_command]. Cmnd_Transfer_Posn) { GPS_User("INFO: GPS position request. Sending...."); ret = GPS_Rqst_Send_Position(fd,gps_save_lat,gps_save_lon); @@ -5677,9 +5551,6 @@ int32 GPS_A500_Send(const char* port, GPS_PAlmanac* alm, int32 n) } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -5898,10 +5769,6 @@ time_t GPS_A600_Get(const char* port) return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, COMMAND_ID[gps_device_command].Cmnd_Transfer_Time); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Command_Data, @@ -5929,9 +5796,6 @@ time_t GPS_A600_Get(const char* port) return PROTOCOL_ERROR; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -5964,10 +5828,6 @@ int32 GPS_A600_Send(const char* port, time_t Time) return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - switch (gps_date_time_type) { case pD600: GPS_D600_Send(&tra,Time); @@ -5999,8 +5859,8 @@ int32 GPS_A600_Send(const char* port, time_t Time) return gps_errno; } - if (rec->type == LINK_ID[gps_link_type].Pid_Command_Data && - GPS_Util_Get_Short(rec->data) == COMMAND_ID[gps_device_command]. + if (rec.type == LINK_ID[gps_link_type].Pid_Command_Data && + GPS_Util_Get_Short(rec.data) == COMMAND_ID[gps_device_command]. Cmnd_Transfer_Posn) { GPS_User("INFO: GPS position request. Sending...."); ret = GPS_Rqst_Send_Position(fd,gps_save_lat,gps_save_lon); @@ -6020,9 +5880,6 @@ int32 GPS_A600_Send(const char* port, time_t Time) } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -6047,7 +5904,7 @@ time_t GPS_D600_Get(GPS_PPacket packet) UC* p; static struct tm ts; - p = packet->data; + p = packet.data; ts.tm_mon = *p++ - 1; ts.tm_mday = *p++; @@ -6121,10 +5978,6 @@ int32 GPS_A700_Get(const char* port, double* lat, double* lon) return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, COMMAND_ID[gps_device_command].Cmnd_Transfer_Posn); @@ -6153,9 +6006,6 @@ int32 GPS_A700_Get(const char* port, double* lat, double* lon) return PROTOCOL_ERROR; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -6185,10 +6035,6 @@ int32 GPS_A700_Send(const char* port, double lat, double lon) return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - switch (gps_position_type) { case pD700: @@ -6207,9 +6053,6 @@ int32 GPS_A700_Send(const char* port, double lat, double lon) } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -6234,7 +6077,7 @@ void GPS_D700_Get(GPS_PPacket packet, double* lat, double* lon) UC* p; double t; - p = packet->data; + p = packet.data; t = GPS_Util_Get_Double(p); *lat = GPS_Math_Rad_To_Deg(t); @@ -6300,10 +6143,6 @@ int32 GPS_A800_On(const char* port, gpsdevh** fd) return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, COMMAND_ID[gps_device_command].Cmnd_Start_Pvt_Data); @@ -6317,9 +6156,6 @@ int32 GPS_A800_On(const char* port, gpsdevh** fd) return FRAMING_ERROR; } - GPS_Packet_Del(&rec); - GPS_Packet_Del(&tra); - return 1; } @@ -6340,10 +6176,6 @@ int32 GPS_A800_Off(const char* port, gpsdevh** fd) GPS_PPacket tra; GPS_PPacket rec; - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, COMMAND_ID[gps_device_command].Cmnd_Stop_Pvt_Data); @@ -6358,9 +6190,6 @@ int32 GPS_A800_Off(const char* port, gpsdevh** fd) } - GPS_Packet_Del(&rec); - GPS_Packet_Del(&tra); - // if(!GPS_Device_Off(*fd)) // return gps_errno; @@ -6382,26 +6211,16 @@ int32 GPS_A800_Get(gpsdevh** fd, GPS_PPvt_Data* packet) GPS_PPacket tra; GPS_PPacket rec; - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - if (!GPS_Packet_Read(*fd, &rec)) { - GPS_Packet_Del(&rec); - GPS_Packet_Del(&tra); return gps_errno; } if (!GPS_Send_Ack(*fd, &tra, &rec)) { - GPS_Packet_Del(&rec); - GPS_Packet_Del(&tra); return gps_errno; } - if (rec->type != LINK_ID[gps_link_type].Pid_Pvt_Data) { - GPS_Packet_Del(&rec); - GPS_Packet_Del(&tra); + if (rec.type != LINK_ID[gps_link_type].Pid_Pvt_Data) { return 0; } @@ -6411,14 +6230,9 @@ int32 GPS_A800_Get(gpsdevh** fd, GPS_PPvt_Data* packet) break; default: GPS_Error("A800_GET: Unknown pvt protocol"); - GPS_Packet_Del(&rec); - GPS_Packet_Del(&tra); return PROTOCOL_ERROR; } - GPS_Packet_Del(&rec); - GPS_Packet_Del(&tra); - return 1; } @@ -6437,7 +6251,7 @@ void GPS_D800_Get(GPS_PPacket packet, GPS_PPvt_Data* pvt) { UC* p; - p = packet->data; + p = packet.data; (*pvt)->alt = GPS_Util_Get_Float(p); p+=sizeof(float); @@ -6509,10 +6323,6 @@ int32 GPS_A906_Get(const char* port, GPS_PLap** lap, pcb_fn cb) return gps_errno; } - if (!(trapkt = GPS_Packet_New()) || !(recpkt = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, COMMAND_ID[gps_device_command].Cmnd_Transfer_Laps); GPS_Make_Packet(&trapkt, LINK_ID[gps_link_type].Pid_Command_Data, @@ -6530,7 +6340,7 @@ int32 GPS_A906_Get(const char* port, GPS_PLap** lap, pcb_fn cb) return gps_errno; } - n = GPS_Util_Get_Short(recpkt->data); + n = GPS_Util_Get_Short(recpkt.data); if (n) if (!((*lap)=(GPS_PLap*)malloc(n*sizeof(GPS_PLap)))) { @@ -6555,7 +6365,7 @@ int32 GPS_A906_Get(const char* port, GPS_PLap** lap, pcb_fn cb) case pD1001: case pD1011: case pD1015: - GPS_D1011b_Get(&((*lap)[i]),recpkt->data); + GPS_D1011b_Get(&((*lap)[i]),recpkt.data); break; default: GPS_Error("A906_Get: Unknown Lap protocol %d\n", gps_lap_type); @@ -6572,7 +6382,7 @@ int32 GPS_A906_Get(const char* port, GPS_PLap** lap, pcb_fn cb) if (!GPS_Send_Ack(fd, &trapkt, &recpkt)) { return gps_errno; } - if (recpkt->type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { + if (recpkt.type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { GPS_Error("A906_Get: Error transferring laps"); return FRAMING_ERROR; } @@ -6582,9 +6392,6 @@ int32 GPS_A906_Get(const char* port, GPS_PLap** lap, pcb_fn cb) return FRAMING_ERROR; } - GPS_Packet_Del(&trapkt); - GPS_Packet_Del(&recpkt); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -6733,10 +6540,6 @@ int32 GPS_A1006_Get return gps_errno; } - if (!(trapkt = GPS_Packet_New()) || !(recpkt = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, COMMAND_ID[gps_device_command].Cmnd_Transfer_Courses); GPS_Make_Packet(&trapkt, LINK_ID[gps_link_type].Pid_Command_Data, @@ -6754,7 +6557,7 @@ int32 GPS_A1006_Get return gps_errno; } - n = GPS_Util_Get_Short(recpkt->data); + n = GPS_Util_Get_Short(recpkt.data); if (n) @@ -6777,7 +6580,7 @@ int32 GPS_A1006_Get switch (gps_course_type) { case pD1006: - GPS_D1006_Get(&((*crs)[i]),recpkt->data); + GPS_D1006_Get(&((*crs)[i]),recpkt.data); break; default: GPS_Error("A1006_Get: Unknown Course protocol %d\n", @@ -6797,7 +6600,7 @@ int32 GPS_A1006_Get if (!GPS_Send_Ack(fd, &trapkt, &recpkt)) { return gps_errno; } - if (recpkt->type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { + if (recpkt.type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { GPS_Error("A1006_Get: Error transferring courses"); return FRAMING_ERROR; } @@ -6807,9 +6610,6 @@ int32 GPS_A1006_Get return FRAMING_ERROR; } - GPS_Packet_Del(&trapkt); - GPS_Packet_Del(&recpkt); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -6843,10 +6643,6 @@ int32 GPS_A1006_Send(const char* port, int32 i; int32 len; - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data,(US) n_crs); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Records, data,2); @@ -6893,9 +6689,6 @@ int32 GPS_A1006_Send(const char* port, return FRAMING_ERROR; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - return 1; } @@ -6984,10 +6777,6 @@ int32 GPS_A1007_Get(const char* port, GPS_PCourse_Lap** clp, pcb_fn cb) return gps_errno; } - if (!(trapkt = GPS_Packet_New()) || !(recpkt = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, COMMAND_ID[gps_device_command].Cmnd_Transfer_Course_Laps); GPS_Make_Packet(&trapkt, LINK_ID[gps_link_type].Pid_Command_Data, @@ -7005,7 +6794,7 @@ int32 GPS_A1007_Get(const char* port, GPS_PCourse_Lap** clp, pcb_fn cb) return gps_errno; } - n = GPS_Util_Get_Short(recpkt->data); + n = GPS_Util_Get_Short(recpkt.data); if (n) @@ -7028,7 +6817,7 @@ int32 GPS_A1007_Get(const char* port, GPS_PCourse_Lap** clp, pcb_fn cb) switch (gps_course_lap_type) { case pD1007: - GPS_D1007_Get(&((*clp)[i]),recpkt->data); + GPS_D1007_Get(&((*clp)[i]),recpkt.data); break; default: GPS_Error("A1007_Get: Unknown Course Lap protocol %d\n", @@ -7048,7 +6837,7 @@ int32 GPS_A1007_Get(const char* port, GPS_PCourse_Lap** clp, pcb_fn cb) if (!GPS_Send_Ack(fd, &trapkt, &recpkt)) { return gps_errno; } - if (recpkt->type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { + if (recpkt.type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { GPS_Error("A1007_Get: Error transferring course laps"); return FRAMING_ERROR; } @@ -7058,9 +6847,6 @@ int32 GPS_A1007_Get(const char* port, GPS_PCourse_Lap** clp, pcb_fn cb) return FRAMING_ERROR; } - GPS_Packet_Del(&trapkt); - GPS_Packet_Del(&recpkt); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -7094,10 +6880,6 @@ int32 GPS_A1007_Send(const char* port, int32 i; int32 len; - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data,(US) n_clp); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Records, data,2); @@ -7144,9 +6926,6 @@ int32 GPS_A1007_Send(const char* port, return FRAMING_ERROR; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - return 1; } @@ -7272,10 +7051,6 @@ int32 GPS_A1008_Get(const char* port, GPS_PCourse_Point** cpt, pcb_fn cb) return gps_errno; } - if (!(trapkt = GPS_Packet_New()) || !(recpkt = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, COMMAND_ID[gps_device_command].Cmnd_Transfer_Course_Points); GPS_Make_Packet(&trapkt, LINK_ID[gps_link_type].Pid_Command_Data, @@ -7293,7 +7068,7 @@ int32 GPS_A1008_Get(const char* port, GPS_PCourse_Point** cpt, pcb_fn cb) return gps_errno; } - n = GPS_Util_Get_Short(recpkt->data); + n = GPS_Util_Get_Short(recpkt.data); if (n) @@ -7316,7 +7091,7 @@ int32 GPS_A1008_Get(const char* port, GPS_PCourse_Point** cpt, pcb_fn cb) switch (gps_course_point_type) { case pD1012: - GPS_D1012_Get(&((*cpt)[i]),recpkt->data); + GPS_D1012_Get(&((*cpt)[i]),recpkt.data); break; default: GPS_Error("A1008_Get: Unknown Course Point protocol %d\n", @@ -7336,7 +7111,7 @@ int32 GPS_A1008_Get(const char* port, GPS_PCourse_Point** cpt, pcb_fn cb) if (!GPS_Send_Ack(fd, &trapkt, &recpkt)) { return gps_errno; } - if (recpkt->type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { + if (recpkt.type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt) { GPS_Error("A1008_Get: Error transferring course points"); return FRAMING_ERROR; } @@ -7346,9 +7121,6 @@ int32 GPS_A1008_Get(const char* port, GPS_PCourse_Point** cpt, pcb_fn cb) return FRAMING_ERROR; } - GPS_Packet_Del(&trapkt); - GPS_Packet_Del(&recpkt); - if (!GPS_Device_Off(fd)) { return gps_errno; } @@ -7383,10 +7155,6 @@ int32 GPS_A1008_Send(const char* port, int32 i; int32 len; - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data,(US) n_cpt); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Records, data,2); @@ -7433,9 +7201,6 @@ int32 GPS_A1008_Send(const char* port, return FRAMING_ERROR; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - return 1; } @@ -7536,10 +7301,6 @@ int32 GPS_A1009_Get(const char* port, GPS_PCourse_Limits limits) return gps_errno; } - if (!(trapkt = GPS_Packet_New()) || !(recpkt = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data, COMMAND_ID[gps_device_command].Cmnd_Transfer_Course_Limits); GPS_Make_Packet(&trapkt, LINK_ID[gps_link_type].Pid_Command_Data, @@ -7559,7 +7320,7 @@ int32 GPS_A1009_Get(const char* port, GPS_PCourse_Limits limits) switch (gps_course_limits_type) { case pD1013: - GPS_D1013_Get(limits,recpkt->data); + GPS_D1013_Get(limits,recpkt.data); break; default: GPS_Error("A1009_Get: Unknown Course Limits protocol %d\n", @@ -7567,9 +7328,6 @@ int32 GPS_A1009_Get(const char* port, GPS_PCourse_Limits limits) return PROTOCOL_ERROR; } - GPS_Packet_Del(&trapkt); - GPS_Packet_Del(&recpkt); - if (!GPS_Device_Off(fd)) { return gps_errno; } diff --git a/gpsbabel/jeeps/gpsapp.h b/gpsbabel/jeeps/gpsapp.h index 6f88fcc6b..2d97110eb 100644 --- a/gpsbabel/jeeps/gpsapp.h +++ b/gpsbabel/jeeps/gpsapp.h @@ -1,8 +1,3 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - #ifndef gpsapp_h #define gpsapp_h @@ -117,7 +112,3 @@ extern "C" void GPS_Prepare_Track_For_Device(GPS_PTrack** trk, int32* n); #endif - -#ifdef __cplusplus -} -#endif diff --git a/gpsbabel/jeeps/gpscom.cc b/gpsbabel/jeeps/gpscom.cc index 629be721e..cce09539a 100644 --- a/gpsbabel/jeeps/gpscom.cc +++ b/gpsbabel/jeeps/gpscom.cc @@ -49,10 +49,6 @@ int32 GPS_Command_Off(const char* port) return gps_errno; } - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - GPS_Util_Put_Short(data,COMMAND_ID[gps_device_command].Cmnd_Turn_Off_Pwr); /* robertl - LINK_ID isn't set yet. Hardcode it to Garmin spec value */ @@ -69,9 +65,6 @@ int32 GPS_Command_Off(const char* port) GPS_User("Power off command acknowledged"); } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - if (!GPS_Device_Off(fd)) { return gps_errno; } diff --git a/gpsbabel/jeeps/gpscom.h b/gpsbabel/jeeps/gpscom.h index 8520312d6..1c8c5f3cb 100644 --- a/gpsbabel/jeeps/gpscom.h +++ b/gpsbabel/jeeps/gpscom.h @@ -1,8 +1,3 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - #ifndef gpscom_h #define gpscom_h @@ -50,7 +45,3 @@ extern "C" int32 GPS_Command_Get_Workout_Limits(const char* port, void** lap, int (*cb)(int, struct GPS_SWay**)); int32 GPS_Command_Get_Course_Limits(const char* port, void** lap, int (*cb)(int, struct GPS_SWay**)); #endif - -#ifdef __cplusplus -} -#endif diff --git a/gpsbabel/jeeps/gpsdatum.h b/gpsbabel/jeeps/gpsdatum.h index ff7475026..1e8502af2 100644 --- a/gpsbabel/jeeps/gpsdatum.h +++ b/gpsbabel/jeeps/gpsdatum.h @@ -1,8 +1,3 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - #ifndef gpsdatum_h #define gpsdatum_h @@ -240,7 +235,3 @@ extern "C" #endif - -#ifdef __cplusplus -} -#endif diff --git a/gpsbabel/jeeps/gpsdevice.cc b/gpsbabel/jeeps/gpsdevice.cc index eef48edd7..221839452 100644 --- a/gpsbabel/jeeps/gpsdevice.cc +++ b/gpsbabel/jeeps/gpsdevice.cc @@ -82,7 +82,7 @@ int32 GPS_Get_Ack(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec) void GPS_Make_Packet(GPS_PPacket* packet, US type, UC* data, uint32 n) { - (*packet)->type = type; - memcpy((*packet)->data, data, n); - (*packet)->n = n; + packet->type = type; + memcpy(packet->data, data, n); + packet->n = n; } diff --git a/gpsbabel/jeeps/gpsdevice.h b/gpsbabel/jeeps/gpsdevice.h index 481826545..cc64eab8b 100644 --- a/gpsbabel/jeeps/gpsdevice.h +++ b/gpsbabel/jeeps/gpsdevice.h @@ -19,11 +19,6 @@ */ -#ifdef __cplusplus -extern "C" -{ -#endif - #ifndef gpsdevice_h #define gpsdevice_h @@ -65,7 +60,3 @@ extern "C" } gps_device_ops; #endif /* gpsdevice.h */ - -#ifdef __cplusplus -} -#endif diff --git a/gpsbabel/jeeps/gpsfmt.h b/gpsbabel/jeeps/gpsfmt.h index 8a7377b37..3f1ce4c9f 100644 --- a/gpsbabel/jeeps/gpsfmt.h +++ b/gpsbabel/jeeps/gpsfmt.h @@ -1,8 +1,3 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - #ifndef gpsfmt_h #define gpsfmt_h @@ -21,7 +16,3 @@ extern "C" int32 GPS_Fmt_Print_Route(GPS_PWay* way, int32 n, FILE* outf); #endif - -#ifdef __cplusplus -} -#endif diff --git a/gpsbabel/jeeps/gpsinput.h b/gpsbabel/jeeps/gpsinput.h index 78c7d73f9..73341b98d 100644 --- a/gpsbabel/jeeps/gpsinput.h +++ b/gpsbabel/jeeps/gpsinput.h @@ -1,8 +1,3 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - #ifndef gpsinput_h #define gpsinput_h @@ -17,7 +12,3 @@ extern "C" #endif - -#ifdef __cplusplus -} -#endif diff --git a/gpsbabel/jeeps/gpsmath.h b/gpsbabel/jeeps/gpsmath.h index 839fece39..b3ecfdbea 100644 --- a/gpsbabel/jeeps/gpsmath.h +++ b/gpsbabel/jeeps/gpsmath.h @@ -1,8 +1,3 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - #ifndef gpsmath_h #define gpsmath_h @@ -144,7 +139,3 @@ extern "C" const char* GPS_Math_Get_Datum_Name(const int datum_index); #endif - -#ifdef __cplusplus -} -#endif diff --git a/gpsbabel/jeeps/gpsmem.cc b/gpsbabel/jeeps/gpsmem.cc index bc0923532..3148898b2 100644 --- a/gpsbabel/jeeps/gpsmem.cc +++ b/gpsbabel/jeeps/gpsmem.cc @@ -30,55 +30,6 @@ #include #include -/* @func GPS_Packet_New *********************************************** -** -** Packet constructor -** -** @return [GPS_PPacket] virgin packet -**********************************************************************/ - -GPS_PPacket GPS_Packet_New(void) -{ - GPS_PPacket ret; - int hdr_size = sizeof(GPS_OPacket) ; - if (!(ret=(GPS_PPacket)calloc(1, hdr_size))) - - { - perror("malloc"); - fprintf(stderr,"GPS_Packet_New: Insufficient memory"); - fflush(stderr); - return NULL; - } - if (!(ret->data = (UC*)calloc(1, MAX_GPS_PACKET_SIZE*sizeof(UC)))) { - perror("malloc"); - fprintf(stderr,"GPS_Packet_New: Insufficient data memory"); - fflush(stderr); - return NULL; - } - - return ret; -} - - -/* @func GPS_Packet_Del *********************************************** -** -** Packet destructor -** -** @param [w] thys [GPS_PPacket *] packet to delete -** -** @return [void] -**********************************************************************/ - -void GPS_Packet_Del(GPS_PPacket* thys) -{ - free((void*)(*thys)->data); - free((void*)*thys); - - return; -} - - - /* @func GPS_Pvt_New *********************************************** ** ** Pvt constructor diff --git a/gpsbabel/jeeps/gpsmem.h b/gpsbabel/jeeps/gpsmem.h index bcf9e71cc..9d6ca3ef3 100644 --- a/gpsbabel/jeeps/gpsmem.h +++ b/gpsbabel/jeeps/gpsmem.h @@ -1,16 +1,8 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - #ifndef gpsmem_h #define gpsmem_h #include "gps.h" - - GPS_PPacket GPS_Packet_New(void); - void GPS_Packet_Del(GPS_PPacket* thys); GPS_PPvt_Data GPS_Pvt_New(void); void GPS_Pvt_Del(GPS_PPvt_Data* thys); GPS_PAlmanac GPS_Almanac_New(void); @@ -29,7 +21,3 @@ extern "C" void GPS_Course_Point_Del(GPS_PCourse_Point* thys); #endif - -#ifdef __cplusplus -} -#endif diff --git a/gpsbabel/jeeps/gpsproj.h b/gpsbabel/jeeps/gpsproj.h index 7206b06d5..8cc210a26 100644 --- a/gpsbabel/jeeps/gpsproj.h +++ b/gpsbabel/jeeps/gpsproj.h @@ -1,8 +1,3 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - #ifndef gpsproj_h #define gpsproj_h @@ -151,7 +146,3 @@ extern "C" double E0, double N0, double a, double b); #endif - -#ifdef __cplusplus -} -#endif diff --git a/gpsbabel/jeeps/gpsprot.h b/gpsbabel/jeeps/gpsprot.h index 3de616848..6c16df083 100644 --- a/gpsbabel/jeeps/gpsprot.h +++ b/gpsbabel/jeeps/gpsprot.h @@ -1,8 +1,3 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - #ifndef gpsprotocols_h #define gpsprotocols_h @@ -380,7 +375,3 @@ extern "C" #endif - -#ifdef __cplusplus -} -#endif diff --git a/gpsbabel/jeeps/gpsread.cc b/gpsbabel/jeeps/gpsread.cc index a2d98f672..9e0171f6e 100644 --- a/gpsbabel/jeeps/gpsread.cc +++ b/gpsbabel/jeeps/gpsread.cc @@ -82,7 +82,7 @@ int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_PPacket* packet) len = 0; isDLE = gpsFalse; - p = (*packet)->data; + p = (*packet).data; start = GPS_Time_Now(); GPS_Diag("Rx Data:"); @@ -108,7 +108,7 @@ int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_PPacket* packet) } if (len==1) { - (*packet)->type = u; + (*packet).type = u; ++len; continue; } @@ -122,45 +122,45 @@ int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_PPacket* packet) } if (len == 2) { - (*packet)->n = u; + (*packet).n = u; len = -1; continue; } if (u == ETX) if (isDLE) { - if (p-(*packet)->data-2 != (*packet)->n) { + if (p-(*packet).data-2 != (*packet).n) { GPS_Error("GPS_Packet_Read: Bad count"); gps_errno = FRAMING_ERROR; return 0; } chk_read = *(p-2); - for (i=0,p=(*packet)->data; i<(*packet)->n; ++i) { + for (i=0,p=(*packet).data; i<(*packet).n; ++i) { chk -= *p++; } - chk -= (*packet)->type; - chk -= (*packet)->n; + chk -= packet->type; + chk -= packet->n; if (chk != chk_read) { GPS_Error("CHECKSUM: Read error\n"); gps_errno = FRAMING_ERROR; return 0; } - m1 = Get_Pkt_Type((*packet)->type, (*packet)->data[0], &m2); + m1 = Get_Pkt_Type((*packet).type, (*packet).data[0], &m2); if (gps_show_bytes) { GPS_Diag(" "); - for (i = 0; i < (*packet)->n; i++) { - char c = (*packet)->data[i]; + for (i = 0; i < packet->n; i++) { + char c = (*packet).data[i]; GPS_Diag("%c", isalnum(c) ? c : '.'); } GPS_Diag(" "); } GPS_Diag("(%-8s%s)\n", m1, m2 ? m2 : ""); - return (*packet)->n; + return (*packet).n; } - if (p - (*packet)->data >= MAX_GPS_PACKET_SIZE) { + if (p - packet->data >= MAX_GPS_PACKET_SIZE) { GPS_Error("GPS_Serial_Packet_Read: Bad payload size/no ETX found"); gps_errno = FRAMING_ERROR; return 0; @@ -195,12 +195,12 @@ int32 GPS_Serial_Get_Ack(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec) return 0; } - if (LINK_ID[0].Pid_Ack_Byte != (*rec)->type) { + if (LINK_ID[0].Pid_Ack_Byte != (*rec).type) { gps_error = FRAMING_ERROR; /* rjl return 0; */ } - if (*(*rec)->data != (*tra)->type) { + if (*(*rec).data != (*tra).type) { gps_error = FRAMING_ERROR; return 0; } diff --git a/gpsbabel/jeeps/gpsread.h b/gpsbabel/jeeps/gpsread.h index c9d280a1e..65d9b3996 100644 --- a/gpsbabel/jeeps/gpsread.h +++ b/gpsbabel/jeeps/gpsread.h @@ -1,8 +1,3 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - #ifndef gpsread_h #define gpsread_h @@ -14,7 +9,3 @@ extern "C" int32 GPS_Serial_Get_Ack(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec); #endif - -#ifdef __cplusplus -} -#endif diff --git a/gpsbabel/jeeps/gpsrqst.cc b/gpsbabel/jeeps/gpsrqst.cc index d65ce05e3..7ae125c37 100644 --- a/gpsbabel/jeeps/gpsrqst.cc +++ b/gpsbabel/jeeps/gpsrqst.cc @@ -72,11 +72,6 @@ static int32 GPS_A600_Rqst(gpsdevh* fd, time_t Time) GPS_PPacket tra; GPS_PPacket rec; - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - - switch (gps_date_time_type) { case pD600: GPS_D600_Send(&tra,Time); @@ -93,9 +88,6 @@ static int32 GPS_A600_Rqst(gpsdevh* fd, time_t Time) return gps_errno; } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - return 1; } @@ -145,19 +137,12 @@ static int32 GPS_A700_Rqst(gpsdevh* fd, double lat, double lon) GPS_PPacket tra; GPS_PPacket rec; - if (!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) { - return MEMORY_ERROR; - } - - switch (gps_position_type) { case pD700: GPS_D700_Send(&tra,lat,lon); break; default: GPS_Error("A700_Rqst: Unknown position protocol"); - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); return PROTOCOL_ERROR; } @@ -170,9 +155,6 @@ static int32 GPS_A700_Rqst(gpsdevh* fd, double lat, double lon) } - GPS_Packet_Del(&tra); - GPS_Packet_Del(&rec); - return 1; } diff --git a/gpsbabel/jeeps/gpsrqst.h b/gpsbabel/jeeps/gpsrqst.h index 0afd29f58..4482066bf 100644 --- a/gpsbabel/jeeps/gpsrqst.h +++ b/gpsbabel/jeeps/gpsrqst.h @@ -1,8 +1,3 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - #ifndef gpsrqst_h #define gpsrqst_h @@ -14,7 +9,3 @@ extern "C" #endif - -#ifdef __cplusplus -} -#endif diff --git a/gpsbabel/jeeps/gpssend.cc b/gpsbabel/jeeps/gpssend.cc index cd5d68a47..b75666aa3 100644 --- a/gpsbabel/jeeps/gpssend.cc +++ b/gpsbabel/jeeps/gpssend.cc @@ -49,25 +49,25 @@ Build_Serial_Packet(GPS_PPacket in, GPS_Serial_PPacket out) UC chk=0; US bytes=0; - p = in->data; + p = in.data; q = out->data; out->dle = DLE; out->edle = DLE; out->etx = ETX; - out->n = in->n; - out->type = in->type; + out->n = in.n; + out->type = in.type; - chk -= in->type; + chk -= in.type; - if (in->n == DLE) { + if (in.n == DLE) { ++bytes; *q++ = DLE; } - chk -= in->n; + chk -= in.n; - for (i = 0; i < in->n; ++i) { + for (i = 0; i < in.n; ++i) { if (*p == DLE) { ++bytes; *q++ = DLE; @@ -126,7 +126,7 @@ int32 GPS_Serial_Write_Packet(gpsdevh* fd, GPS_PPacket packet) UC ser_pkt_data[MAX_GPS_PACKET_SIZE * sizeof(UC)]; US bytes; - if (packet->type >= 0xff || packet->n >= 0xff) { + if (packet.type >= 0xff || packet.n >= 0xff) { GPS_Error("SEND: Unsupported packet type/size for serial protocol"); return 0; } @@ -176,7 +176,6 @@ int32 GPS_Serial_Write_Packet(gpsdevh* fd, GPS_PPacket packet) return 0; } - return 1; } @@ -196,7 +195,7 @@ int32 GPS_Serial_Send_Ack(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec) { UC data[2]; - GPS_Util_Put_Short(data,(US)(*rec)->type); + GPS_Util_Put_Short(data,(US)rec->type); GPS_Make_Packet(tra,LINK_ID[0].Pid_Ack_Byte,data,2); if (!GPS_Write_Packet(fd,*tra)) { GPS_Error("Error acknowledging packet"); diff --git a/gpsbabel/jeeps/gpssend.h b/gpsbabel/jeeps/gpssend.h index 68b480291..f93b6585e 100644 --- a/gpsbabel/jeeps/gpssend.h +++ b/gpsbabel/jeeps/gpssend.h @@ -1,8 +1,3 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - #ifndef gpssend_h #define gpssend_h @@ -18,7 +13,3 @@ extern "C" #endif - -#ifdef __cplusplus -} -#endif diff --git a/gpsbabel/jeeps/gpsserial.h b/gpsbabel/jeeps/gpsserial.h index 1ebda4703..95879853c 100644 --- a/gpsbabel/jeeps/gpsserial.h +++ b/gpsbabel/jeeps/gpsserial.h @@ -1,8 +1,3 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - #ifndef gpsserial_h #define gpsserial_h @@ -30,7 +25,3 @@ extern "C" #endif - -#ifdef __cplusplus -} -#endif diff --git a/gpsbabel/jeeps/gpsusbread.cc b/gpsbabel/jeeps/gpsusbread.cc index 7fb20386c..5e392beee 100644 --- a/gpsbabel/jeeps/gpsusbread.cc +++ b/gpsbabel/jeeps/gpsusbread.cc @@ -90,7 +90,7 @@ do_over: * (Since the protocol packets was badly exposed in the core * design of jeeps) is even more painful. */ - (*packet)->type = le_read16(&pkt.gusb_pkt.pkt_id); + packet->type = le_read16(&pkt.gusb_pkt.pkt_id); payload_size = le_read32(&pkt.gusb_pkt.datasz); if (payload_size<0 || payload_size>MAX_GPS_PACKET_SIZE) { /* If you get this, the packet might have been corrupted @@ -101,8 +101,8 @@ do_over: gps_errno = FRAMING_ERROR; return 0; } - (*packet)->n = payload_size; - memcpy((*packet)->data, &pkt.gusb_pkt.databuf, payload_size); + packet->n = payload_size; + memcpy(packet->data, &pkt.gusb_pkt.databuf, payload_size); return 1; } diff --git a/gpsbabel/jeeps/gpsusbsend.cc b/gpsbabel/jeeps/gpsusbsend.cc index 420445f4d..5f7eceebe 100644 --- a/gpsbabel/jeeps/gpsusbsend.cc +++ b/gpsbabel/jeeps/gpsusbsend.cc @@ -37,9 +37,9 @@ GPS_Write_Packet_usb(gpsdevh* dh, GPS_PPacket packet) * the USB packet that we will put on the wire. */ gp.gusb_pkt.type = 0x14; - le_write16(&gp.gusb_pkt.pkt_id, packet->type); - le_write32(&gp.gusb_pkt.datasz, packet->n); - memcpy(&gp.gusb_pkt.databuf, packet->data, packet->n); + le_write16(&gp.gusb_pkt.pkt_id, packet.type); + le_write32(&gp.gusb_pkt.datasz, packet.n); + memcpy(&gp.gusb_pkt.databuf, packet.data, packet.n); - return gusb_cmd_send(&gp, packet->n + 12); + return gusb_cmd_send(&gp, packet.n + 12); } diff --git a/gpsbabel/jeeps/gpsutil.h b/gpsbabel/jeeps/gpsutil.h index 3b8f25dac..2f7083080 100644 --- a/gpsbabel/jeeps/gpsutil.h +++ b/gpsbabel/jeeps/gpsutil.h @@ -1,8 +1,3 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - #ifndef gpsutil_h #define gpsutil_h @@ -43,7 +38,3 @@ extern "C" #endif - -#ifdef __cplusplus -} -#endif diff --git a/gpsbabel/mmo.cc b/gpsbabel/mmo.cc index c71d82c43..b99720c47 100644 --- a/gpsbabel/mmo.cc +++ b/gpsbabel/mmo.cc @@ -148,7 +148,9 @@ static const mmo_icon_mapping_t mmo_icon_value_table[] = { static const uint32_t obj_type_ico = 0x00; static const uint32_t obj_type_rte = 0x14; static const uint32_t obj_type_trk = 0x1E; +#ifdef MMO_DBG static const uint32_t obj_type_txt = 0x32; +#endif static const uint32_t obj_type_wpt = 0x3C; /* helpers */ -- 2.30.2